using System;
using System.Collections.Generic;
using System.Text;
using SlimDX;
using System.Runtime.InteropServices;
using SlimDX.Direct3D9;

namespace Barrage.Global.Vertex
{
    /// <summary>
    /// Vertex format with position, color, texture coordinates and normal
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    public struct VertexPositionColorUVNormal
    {
        /// <summary>
        /// Vertex Position
        /// </summary>
        public Vector3 Position;
        /// <summary>
        /// Vertex Normal
        /// </summary>
        public Vector3 Normal;
        /// <summary>
        /// Texture coordinates
        /// </summary>
        public Vector2 UV;
        /// <summary>
        /// Vertex color
        /// </summary>
        public Color4 Color;
        
        /// <summary>
        /// Size in bytes of the vertex format
        /// </summary>
        public static int SizeBytes
        {
            get { return Marshal.SizeOf(typeof(VertexPositionColorUVNormal)); }
        }

        /// <summary>
        /// Array of VertexElements holding this vertex format's declaration
        /// </summary>
        public static VertexElement[] Elements = new VertexElement[]{
                            new VertexElement(0,0,DeclarationType.Float3,DeclarationMethod.Default,DeclarationUsage.Position,0),
                            new VertexElement(0,12,DeclarationType.Float3,DeclarationMethod.Default,DeclarationUsage.Normal,0),
                            new VertexElement(0,24,DeclarationType.Float2,DeclarationMethod.Default,DeclarationUsage.TextureCoordinate,0),
                            new VertexElement(0,32,DeclarationType.Float4,DeclarationMethod.Default,DeclarationUsage.Color,0),                            
                            VertexElement.VertexDeclarationEnd
                        };

        /// <summary>
        /// Constructor. Inits values
        /// </summary>
        /// <param name="position">Vertex position</param>
        /// <param name="color">Vertex color</param>
        /// <param name="UV">Texture coordinates</param>
        /// <param name="normal">Vertex normal</param>
        public VertexPositionColorUVNormal(Vector3 position, Color4 color, Vector2 UV,Vector3 normal)
        {
            this.Position = position;
            this.Color = color;
            this.UV = UV;
            this.Normal = normal;
        }
    }
}
